package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.ctrl.domain.ExinspSaalAnode;
import com.deyuanyun.pic.ctrl.enumeration.AbnormalEnum;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * 牺牲阳极检测记录表
 */
public class ExinspSaalAnodeVO extends ExinspBaseVO<ExinspSaalAnode> {

    // 所属管道
    private String pipeLineName;
    // 设备编号(自定义编号)
    private String customNumber;
    // 测试桩编号
    private String testStationNum;
    // 通电电位
    public Long onPotential;
    // 牺牲阳极开路电位（mV）
    public Long sacalAnodeOpenPotential;
    // 阳极输出电流（mA）
    private BigDecimal currentOut;
    // 接地电阻（Ω）
    private BigDecimal groundingResistance;
    // 土壤电阻率（Ω﹒m）
    private BigDecimal soilResistivity;
    // 牺牲阳极维护
    private String sacrificialAnodeMaintenance;
    // 异常记录
    private String faultRecord;
    // 是否有异常(YES、NO)
    private String abnormal;
    // 处理措施
    private String treatmentMeasures;
    // 检测日期
    private String detectiongDete;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getTestStationNum() {
        return testStationNum;
    }

    public void setTestStationNum(String testStationNum) {
        this.testStationNum = testStationNum;
    }

    public Long getOnPotential() {
        return onPotential;
    }

    public void setOnPotential(Long onPotential) {
        this.onPotential = onPotential;
    }

    public Long getSacalAnodeOpenPotential() {
        return sacalAnodeOpenPotential;
    }

    public void setSacalAnodeOpenPotential(Long sacalAnodeOpenPotential) {
        this.sacalAnodeOpenPotential = sacalAnodeOpenPotential;
    }

    public BigDecimal getCurrentOut() {
        return currentOut;
    }

    public void setCurrentOut(BigDecimal currentOut) {
        this.currentOut = currentOut;
    }

    public BigDecimal getGroundingResistance() {
        return groundingResistance;
    }

    public void setGroundingResistance(BigDecimal groundingResistance) {
        this.groundingResistance = groundingResistance;
    }

    public BigDecimal getSoilResistivity() {
        return soilResistivity;
    }

    public void setSoilResistivity(BigDecimal soilResistivity) {
        this.soilResistivity = soilResistivity;
    }

    public String getSacrificialAnodeMaintenance() {
        return sacrificialAnodeMaintenance;
    }

    public void setSacrificialAnodeMaintenance(String sacrificialAnodeMaintenance) {
        this.sacrificialAnodeMaintenance = sacrificialAnodeMaintenance;
    }

    public String getFaultRecord() {
        return faultRecord;
    }

    public void setFaultRecord(String faultRecord) {
        this.faultRecord = faultRecord;
    }

    public String getAbnormal() {
        return abnormal;
    }

    public void setAbnormal(String abnormal) {
        this.abnormal = abnormal;
    }

    public String getTreatmentMeasures() {
        return treatmentMeasures;
    }

    public void setTreatmentMeasures(String treatmentMeasures) {
        treatmentMeasures = treatmentMeasures;
    }

    public String getDetectiongDete() {
        return detectiongDete;
    }

    public void setDetectiongDete(String detectiongDete) {
        this.detectiongDete = detectiongDete;
    }

    public void fromDomain(ExinspSaalAnode domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 设备编号(自定义编号)
        this.customNumber = domain.getCustomNumber();
        // 测试桩编号
        this.testStationNum = domain.getTestStationId();
        // 通电电位
        this.onPotential = domain.getOnPotential();
        // 牺牲阳极开路电位（mV）
        this.sacalAnodeOpenPotential = domain.getSacalAnodeOpenPotential();
        // 阳极输出电流（mA）
        this.currentOut = domain.getCurrentOut();
        // 接地电阻（Ω）
        this.groundingResistance = domain.getGroundingResistance();
        // 土壤电阻率（Ω﹒m）
        this.soilResistivity = domain.getSoilResistivity();
        // 牺牲阳极维护
        this.sacrificialAnodeMaintenance = domain.getSacrificialAnodeMaintenance();
        // 异常记录
        this.faultRecord = domain.getFaultRecord();
        // 是否有异常(YES、NO)
        this.abnormal = AbnormalEnum.getLabel(domain.getAbnormal());
        // 处理措施
        this.treatmentMeasures = domain.getUpdateRemark();
        // 检测日期
        this.detectiongDete = DateFormat.format(domain.getDetectiongDete());

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<ExinspSaalAnodeVO> fromDomainList(Page<ExinspSaalAnode> domainList) {

        Page<ExinspSaalAnodeVO> list = new Page<ExinspSaalAnodeVO>();
        for (ExinspSaalAnode exinspSaalAnode : domainList) {
            ExinspSaalAnodeVO exinspSaalAnodeVO = new ExinspSaalAnodeVO();
            exinspSaalAnodeVO.fromDomain(exinspSaalAnode);
            list.add(exinspSaalAnodeVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}